package com.greate.rabbit.springbootrabbitmqdemo.routing;

import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

@Component
public class DirectConsumer {
	/**
	 * 消费者1
	 */
	@RabbitListener(bindings = @QueueBinding(
		value = @Queue, exchange = @Exchange(value = "logs_direct", type = "direct"), key = {"info", "error", "warn"}
	))
	public void receive1(String message) {

		System.out.println("消费者1 ：" + message);
	}

	/**
	 * 消费者2
	 */
	@RabbitListener(bindings = @QueueBinding(value = @Queue, exchange = @Exchange(value = "logs_direct", type = "direct"), key = {"warn"}))
	public void receive2(String message) {
		System.out.println("消费者2：" + message);
	}
}


